<?php

use think\migration\Migrator;
use think\migration\db\Column;
use Phinx\Db\Adapter\MysqlAdapter;

class CreateSystemNavTable extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
     /**
     * Migrate Up.
     */
    public function up()
    {
        $table = $this->table('system_nav', ['engine' => 'InnoDB', 'collation' => 'utf8_general_ci', 'comment' => '' ,'id' => 'nav_id' ,'primary_key' => ['nav_id']]);
        $table->addColumn('func_code', 'string', ['limit' => 36,'null' => true,'signed' => true,'comment' => '功能代码',])
            ->addColumn('nav_name', 'string', ['limit' => 200,'null' => true,'signed' => true,'comment' => '导航名称',])
            ->addColumn('nav_url', 'string', ['limit' => 200,'null' => true,'signed' => true,'comment' => '对应路由',])
            ->addColumn('nav_status', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'default' => 0,'signed' => true,'comment' => '导航状态',])
            ->addColumn('nav_pid', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '导航父id',])
            ->addColumn('sort', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '排序',])
            ->addColumn('icon', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => '图标',])
            ->addColumn('type', 'enum', ['values' => ['1','2','3','4']])
            ->addColumn('create_time', 'timestamp', ['null' => true,'signed' => true,'comment' => '创建时间',])
            ->addIndex(['nav_pid'], ['name' => 'nav_pid'])
            ->addIndex(['nav_url'], ['name' => 'nav_url'])
            ->addIndex(['nav_id'], ['name' => 'nav_id'])
            ->create();
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $this->dropTable('system_nav');
    }
    
}
